package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsFootprint;
import com.qf.service.DtsFootprintService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Zwnan
 */
@RestController
@RequestMapping("admin/footprint")
@CrossOrigin
public class FootprintController {
    @Autowired
    private DtsFootprintService dtsFootprintService;

    @RequestMapping("list")
    public Object footprintList(@RequestParam(defaultValue = "1") Integer page
            ,@RequestParam(defaultValue = "20") Integer limit
            ,@RequestParam(defaultValue = "add_time") String sort
            ,@RequestParam(defaultValue = "desc") String order){

        IPage<DtsFootprint> iPage = dtsFootprintService.selectPage(page,limit,sort,order);
        long total = iPage.getTotal();
        List<DtsFootprint> records = iPage.getRecords();
        Map map = new HashMap();
        map.put("total", total);
        map.put("items", records);
        return ResponseUtil.ok(map);

    }

}
